import Vuex from "vuex"
import Vue from "vue"

Vue.use(Vuex);

const store  = new Vuex.Store({

    state:{
        calResult: 0,
        operator:'',
        currentTotalStr:'0'
    },
    mutations:{
        
        updateCurrentTotalStr(state:any,val:string)
        {
           state.currentTotalStr+=val;
        },


        updateCalResult(state:any,val:string|number){

            state.calResult = val
            state.currentTotalStr = val

        },

        updateOperator(state:any,val:string|number){

            state.operator = val;
        },

        clear(state:any){

            state.calResult = 0
            state.currentTotalStr = '0'

        },

        equal(state:any){

            state.currentTotalStr = state.calResult

        }
    }
})


export default store;